<template>
  <view class="order-page">
    <view class="header">
      <image class="logo" src="/static/logo.png" />
      <text class="title">婚纱摄影订单</text>
    </view>
    <view class="content">
      <view class="order-info">
        <text class="info-title">订单信息</text>
        <view class="info-item">
          <text class="label">订单号:</text>
          <text class="value">{{ order.orderNumber }}</text>
        </view>
        <view class="info-item">
          <text class="label">客户姓名:</text>
          <text class="value">{{ order.customerName }}</text>
        </view>
        <view class="info-item">
          <text class="label">拍摄日期:</text>
          <text class="value">{{ order.shootDate }}</text>
        </view>
        <view class="info-item">
          <text class="label">拍摄地点:</text>
          <text class="value">{{ order.shootLocation }}</text>
        </view>
        <view class="info-item">
          <text class="label">套餐类型:</text>
          <text class="value">{{ order.packageType }}</text>
        </view>
      </view>
      <view class="order-actions">
        <button class="action-button" @click="showModal = true">确认订单</button>
        <button class="action-button" @click="cancelOrder">申请退款</button>
      </view>
    </view>
    <view class="footer">
      <text class="footer-text">感谢您的选择，祝您拍摄愉快！</text>
    </view>

    <!-- 模态框 -->
    <view class="modal" v-if="showModal" @click="showModal = false">
      <view class="modal-content" @click.stop>
        <view class="modal-title">确认订单</view>
        <view class="modal-text">您确定要确认此订单吗？</view>
        <view class="modal-actions">
          <button class="modal-button confirm" @click="confirmOrder">确认</button>
          <button class="modal-button cancel" @click="showModal = false">取消</button>
        </view>
      </view>
    </view>
  </view>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';
import { useRouter } from 'vue-router';

interface Order {
  orderNumber: string;
  customerName: string;
  shootDate: string;
  shootLocation: string;
  packageType: string;
}

export default defineComponent({
  setup() {
    const order = ref<Order>({
      orderNumber: '20230401001',
      customerName: '张三',
      shootDate: '2023-05-01',
      shootLocation: '浪漫海岸',
      packageType: '豪华套餐'
    });

    const showModal = ref(false);
    const router = useRouter();

    const confirmOrder = () => {
      uni.showToast({
        title: '订单已确认',
        icon: 'success',
        duration: 1000
      });
      setTimeout(() => {
        router.push('/pages/toUseOrder/toUseOrder');
      }, 1000);
    };

    const cancelOrder = () => {
      console.log('订单已取消');
    };

    return {
      order,
      showModal,
      confirmOrder,
      cancelOrder
    };
  }
});
</script>

<style scoped>
.order-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background: linear-gradient(135deg, #ff6a00, #ee0979);
  color: #fff;
  min-height: 100vh;
  overflow-y: auto;
}

.header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
  animation: fadeIn 1s ease-in-out;
}

.logo {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  margin-bottom: 10px;
  animation: spin 2s linear infinite;
}

.title {
  font-size: 24px;
  font-weight: bold;
}

.content {
  width: 100%;
  max-width: 600px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  animation: slideIn 1s ease-in-out;
}

.order-info {
  margin-bottom: 20px;
}

.info-title {
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 10px;
}

.info-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.label {
  font-weight: bold;
}

.value {
  flex-grow: 1;
  text-align: right;
}

.order-actions {
  display: flex;
  justify-content: space-around;
}

.action-button {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  background: #fff;
  color: #ff6a00;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.3s, color 0.3s;
  animation: pulse 1s ease-in-out infinite;
}

.action-button:hover {
  background: #ff6a00;
  color: #fff;
}

.footer {
  margin-top: 20px;
  text-align: center;
  animation: fadeIn 1s ease-in-out;
}

.footer-text {
  font-size: 14px;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.3s ease-in-out;
}

.modal-content {
  background: #fff;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  animation: scaleIn 0.3s ease-in-out;
}

.modal-title {
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 10px;
  color: #ff6a00;
}

.modal-text {
  font-size: 16px;
  margin-bottom: 20px;
  color: #333;
}

.modal-actions {
  display: flex;
  justify-content: space-around;
}

.modal-button {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.3s, color 0.3s;
}

.modal-button.confirm {
  background: #ff6a00;
  color: #fff;
}

.modal-button.confirm:hover {
  background: #ee0979;
}

.modal-button.cancel {
  background: #ccc;
  color: #333;
}

.modal-button.cancel:hover {
  background: #999;
  color: #fff;
}

@media (max-width: 600px) {
  .content {
    padding: 10px;
  }

  .info-title {
    font-size: 18px;
  }

  .info-item {
    flex-direction: column;
  }

  .value {
    text-align: left;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}
</style>